Skip to content

Add MeshCore pyMC poller, mesh link SNR alerts, and APRS weather parsing#67

Open
d3mocide wants to merge 1 commit into
mainfrom
claude/aprs-meshcore-snr-review-LuzK4
Open

Add MeshCore pyMC poller, mesh link SNR alerts, and APRS weather parsing#67
d3mocide wants to merge 1 commit into
mainfrom
claude/aprs-meshcore-snr-review-LuzK4

Conversation

@d3mocide
Copy link
Copy Markdown
Owner

Summary

This PR adds three major features to enhance mesh network monitoring and APRS weather station support:

  1. MeshCore pyMC poller — A new direct-access poller for MeshCore devices that captures bi-directional link metrics (SNR measured by each remote node) via the meshcore Python library, supporting both TCP and serial connections.

  2. Mesh link SNR threshold alerts — A new alert infrastructure that monitors per-link SNR history and fires mesh_link_degraded events when links drop below configured thresholds, with cooldown gating to prevent alert floods.

  3. APRS weather station support — Enhanced APRS poller to parse Ultimeter/Davis-style weather comments and display live conditions (temperature, humidity, wind, pressure, rainfall) in the entity detail panel.

Key Changes

Backend & Poller

  • poller/pollers/meshcore_pymc.py (new)

    • Direct pyMC poller connecting to MeshCore devices over TCP or serial
    • Fetches full contact list and per-contact neighbour tables
    • Publishes mesh nodes as entities with TTL-based caching
    • Upserts bidirectional link metrics (SNR from remote node perspective) to mesh_links table
    • Supports URL-based configuration: tcp://host:port or serial:///dev/ttyUSB0?baudrate=9600
  • poller/mesh_link_alerts.py (new)

    • SNR threshold monitoring with per-link history tracking
    • Falling-edge detection (fires alert only when SNR crosses below threshold)
    • Per-link cooldown gating (300s default) to prevent alert floods
    • Caches thresholds from mesh_alert_configs table with 60s TTL
    • Publishes mesh_link_degraded events to database and Redis pub/sub
  • db/init/10_mesh_alert_config.sql (new)

    • New mesh_alert_configs table for per-source SNR thresholds and cooldown settings
    • Unique index on source_url for efficient lookups
  • poller/pollers/meshcore.py (modified)

    • Integrated SNR threshold checking after each link upsert
    • Calls check_link_degradation() for each link with valid SNR
  • poller/pollers/aprs.py (modified)

    • Parses Ultimeter/Davis weather comments for weather stations
    • Stores parsed weather data (temp_f, humidity, wind_mph, pressure_mb, rain_in, etc.) in entity identity
  • poller/enrichment/aprs_weather.py (new)

    • Regex-based parser for standard APRS weather comment format
    • Handles optional fields in any order
    • Converts units (knots → mph, 0.1 mbar → mb, 0.01 in → in)
    • Returns None if no weather data detected
  • poller/main.py (modified)

    • Registered MeshCorePymcPoller in poller registry
  • poller/requirements.txt (modified)

    • Added meshcore>=2.3.0 dependency

Backend API

  • backend/routers/mesh.py (modified)
    • Added include_coords query parameter to /mesh/topology endpoint
    • When enabled, enriches node list with lat/lon from Redis entity cache
    • Returns nodes as objects with id, lat, lon instead of bare strings

Frontend

  • frontend/src/components/panels/entity/AprsOverview.tsx (modified)

    • Added weather data card for APRS weather stations
    • Displays temperature, humidity, wind (with directional arrow), pressure, and rainfall
    • Wind arrow component rotates based on wind direction
    • Only shown when station_type === 'weather' and weather data is present
  • **`frontend

https://claude.ai/code/session_01J3kpNrV5xm55N17Uu7NU61

1A — /mesh/topology?include_coords=true enriches each node with
lat/lon fetched via Redis MGET on entity:{node_id} keys.

1B — APRS weather comment parser (poller/enrichment/aprs_weather.py)
extracts temp, humidity, pressure, wind, rain from Ultimeter/Davis
comment strings; wired into aprs.py for station_type=weather entities,
stored under identity.wx.

1C — SNR threshold alert infrastructure: mesh_link_alerts.py tracks
per-link SNR history and fires mesh_link_degraded events on the falling
edge with a cooldown gate; wired into _upsert_mesh_links in meshcore.py.
DB migration 10_mesh_alert_config.sql adds the per-source config table.

Feature 3 — APRS weather panel: AprsOverview shows a live conditions
card (temp/humidity/pressure/wind/rain) when identity.wx is present;
EntityDetail exposes a Weather tab for APRS weather stations alongside
the existing aircraft METAR tab.

pyMC poller — meshcore_pymc.py uses the `meshcore` Python library
(meshcore>=2.3.0) to connect directly to a MeshCore device over TCP
or serial, fetching the full contact table with adv_lat/adv_lon
coordinates and calling fetch_all_neighbours() per contact to capture
SNR as measured by remote nodes — a dimension unavailable via the
RemoteTerm REST/WS path.

Also notes: Feature 1 (APRS symbol color-coding) was already complete
in buildEntityLayers.ts (aprsColor, emergencyRingLayer, aprsLabelLayer).

https://claude.ai/code/session_01J3kpNrV5xm55N17Uu7NU61
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants